// 阻止组件渲染
import React from 'react'
function Page (props) {
    if (!props.showWarning) {
        return null
    }
    return (<div className='warning'>Warning</div>)
}
class WarningBanner extends React.Component {
  constructor (props) {
    super(props)
    this.state = {
      showWarning: true
    }
  }
  handelShow = ()=>{
      this.setState({
        showWarning: !this.state.showWarning
      })
  }
  render () {
    return (
      <div>
        <Page showWarning={this.state.showWarning}></Page>
        <button onClick={this.handelShow}>点我</button>
      </div>
    )
  }
}
export { WarningBanner }
